# class Student:
#     def __init__(self, sid, name, age):
#         self.sid = sid
#         self.name = name
#         self.age = age
#
#     def __str__(self):
#         return f"编号:{self.sid}\t姓名：{self.name}\t年纪：{self.age}"


# s1 = Student(101, "小张", 20)
# # print(s1)
# s2 = Student(102, "小李", 21)
# # print(s2)
#
# students = []
# students.append(s1)
# students.append(s2)
#
# for s in students:
#     print(s)


# class StudentManage:
#     def __init__(self):
#         self.students = []
#
#
#     def add_student(self, name, age):
#         sid = 101 if not self.students else self.students[-1].sid + 1
#         s = Student(sid, name, age)
#         self.students.append(s)
#
#     def show_all_students(self):
#         for s in self.students:
#             print(s)
#
#     def show_student_by_id(self, sid):
#         for s in self.students:
#             if s.sid == sid:
#                 print(s)
#                 break
#         else:
#             print(f"没有找到sid为{sid}的学生")
#
#     def remove_student_by_id(self, sid):
#         for s in self.students:
#             if s.sid == sid:
#                 self.students.remove(s)
#                 break
#         else:
#             print(f"没有找到sid为{sid}的学生")
#
#     def show_studnets_age_lt_20(self):
#         for s in self.students:
#             if s.age < 20:
#                 print(s)
#
#
#
# def main():
#     sm = StudentManage()
#     sm.add_student("小张", 10)
#     sm.add_student("小王", 30)
#     sm.show_all_students()
#
#     sm.show_student_by_id(103)
#     sm.show_student_by_id(102)
#
#     sm.remove_student_by_id(102)
#     sm.show_student_by_id(102)
#
#     sm.show_studnets_age_lt_20()
#
# main()


# 封装圆形类，
# 包含数据，圆心(x,y)，半径(r)
# 包含方法，面积与周长
#
#
# 封装管理类，管理10个 半径位于10-30之间的圆  位置在【0，0， 100， 100】
# 封装方法
#     找到面积最大的圆
#     找到距离最远的两个圆


import math
import random


class Circle:
    def __init__(self, x, y, r):
        self.x = x
        self.y = y
        self.r = r

    def get_length(self):
        return 2 * math.pi * self.r

    def get_area(self):
        return math.pi * self.r * self.r

    def __str__(self):
        return f"当前圆信息 X:{self.x}\tY:{self.y}\tArea:{self.get_area()}\tLength:{self.get_length()}"


# c1 = Circle(10, 10, 10)
# c2 = Circle(30, 30, 5)
# # print(c1.get_length(), c1.get_area(), c2.get_length(), c2.get_area())
# l0 = []
# l0.append(c1)
# l0.append(c2)
# for c in l0:
#     print(c.get_area(), c.get_length())



class CircleManage:
    def __init__(self):
        self.circles = []

    def add_circle(self, c):
        self.circles.append(c)

    def get_max_area(self):
        # return max(self.circles, key=lambda c: c.get_area())

        max_c = None
        max_c_area = 0
        for c in self.circles:
            if max_c is None:
                max_c = c
            else:
                if max_c_area < c.get_area():
                    max_c_area = c.get_area()
                    max_c = c

        return max_c

    def get_max_distance(self):
        max_dis = 0
        circles = []
        for i in range(len(self.circles)-1):
            for j in range(i+1, len(self.circles)):
                dis = math.sqrt((self.circles[i].y - self.circles[j].y) ** 2 + (self.circles[i].x - self.circles[j].x) ** 2)
                if max_dis < dis:
                    max_dis = dis
                    circles.clear()
                    circles.append(self.circles[i])
                    circles.append(self.circles[j])
        return circles


def main():
    cm = CircleManage()
    for i in range(10):
        c = Circle(random.randint(0, 100), random.randint(0, 100), random.randint(10, 30))
        print(c)
        cm.add_circle(c)
    print(f"面集最大的圆 {cm.get_max_area()}")

    for c in cm.get_max_distance():
        print(c)

main()